    #-*- coding: UTF-8 -*-    
    #Copyright (c) 2013 LL. All Rights Reserved.
    #
import os.path
import ConfigParser

#@brief                输出指定路径下指定文件类型到文件
def getfiles():
    resultfile = open('Restlt.txt','w')
    Path,Types = getconfig()    
    for dirpath, dirnames, filenames in os.walk(Path):
        for filename in filenames:
            for Type in Types:
                if os.path.splitext(filename)[1] == '.'+Type:
                    filepath = os.path.join(dirpath, filename)
                    resultfile.write(filepath+'\n')                    
    resultfile.close()
    
#@brief 读取配置Path Type
def getconfig():
    conf = ConfigParser.ConfigParser()
    conf.read("files.ini");
    Path = conf.get("Path", "Path")
    Type = conf.get("Type", "Type")   
    result = []
    types = Type.split(';')
    for item in types:       
        result.append(item.split('.')[1])        
    return Path, result    
    
#@brief For test
def test():
    print getconfig()

if __name__=="__main__":
    getfiles()


